<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <div th:include="public/css"></div>
</head>
<body>
    <div class="layui-btn-container">
        <a class="layui-btn"  href="/StockAnaly/add" > <i class="layui-icon">&#xe654;</i>新增</a>
    </div>
    <div class="layui-form">
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">股票名称</label>
            <div class="layui-input-inline">
                <input type="text" name="stockName" th:value="${vo?.stockName}"    autocomplete="off" class="layui-input" >
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">股票代码</label>
            <div class="layui-input-inline">
                <input type="text" name="stockName" th:value="${vo?.stockCd}"    autocomplete="off" class="layui-input" >
            </div>
        </div>
    </div>
    <input type="text" id="scd" name="cd" th:value="${stockCd}"    autocomplete="off" class="layui-hide" >
    <table class="layui-hide" id="datas" lay-filter="table1"></table>
</body>
<div th:include="public/js"></div>

<script type="text/html" id="toolbar">
    <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit"><i class="layui-icon">&#xe642;</i>修改</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon">&#xe640;</i>删除</a>
</script>

<script>
    layui.use('table', function(){
        var table = layui.table;
        var layer = layui.layer
        // var scd = ${stockCd}
        var input = document.getElementById("scd")


        layer.msg(input.value)
        table.render({
            elem: '#datas'
            ,cellMinWidth: 80 //全局定义常规单元格的最小宽度，layui 2.2.1 新增
            ,url:"/StockAnaly/listsByCode?stockCd="+input.value
            ,cols: [ [
                {field:'id',  title: 'ID',  hide:true}
                ,{field:'stockName',  title: '股票名称'}
                ,{field:'stockCd',  title: '股票代码'}
                ,{field:'stage',  title: '阶段'}
                ,{field:'modifyLine',  title: '变线'}
                ,{field:'support', title: '支撑或阻力'}
                ,{field:'movingAverage', title: '移动平均线'}
                ,{field:'volume', title: '交易量'}
                ,{field:'callBack', title: '回调'}
                ,{field:'appraise', title: '评价'}
                ,{field:'createTime', hide:true, sort:true}
                ,{fixed:'right', title: '操作', align:'center',toolbar:'#toolbar'}
            ] ],
        });

        //监听工具条
        table.on('tool(table1)', function(obj){ //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
            var data = obj.data; //获得当前行数据
            var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
            var tr = obj.tr; //获得当前行 tr 的DOM对象

            if(layEvent === 'del'){ //删除
                layer.confirm('真的删除行么', function(index){
                    layer.close(index2);
                    var url = "/StockAnaly/doDel?id="+data.id;
                    api.del(url,layer,obj);
                });
            } else if(layEvent === 'edit'){ //编辑
                location.href = "/StockAnaly/edit?id="+data.id;
            }
        });

    });
</script>
</html>